import resolve from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import { terser } from "rollup-plugin-terser";
import typescript from "rollup-plugin-typescript";

export default {
    input: "src/utils/index.ts", // 输入文件路径
    output: [
        {
            file: "dist/FormStorage.cjs.ts", // CommonJS 产物路径
            format: "cjs",
            sourcemap: true,
        },
        {
            file: "dist/FormStorage.esm.ts", // ES 模块产物路径
            format: "esm",
            sourcemap: true,
        },
        {
            file: "dist/FormStorage.umd.ts", // UMD 产物路径
            format: "umd",
            name: "FormStorage",
            sourcemap: true,
        },
    ],
    plugins: [
        resolve(), // 使 Rollup 能够找到 node_modules 中的模块
        commonjs(), // 使 Rollup 能够转换 CommonJS 模块为 ES6
        terser(), // 压缩代码
        typescript(),
    ],
};
